home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1998 January / CT_SW9801.ISO / pc / software / dateiman / backup / suntr214.sit / about Macintosh devices next >
Text File  |  1996-11-03  |  11KB  |  59 lines

  1. Introduction to devices
  2.  
  3.   If you want to use suntar 2.0 or later only on floppy disks, as you did with previous versions, you need no more informations. But otherwise, you're entering a world which is not well known to normal Macintosh users, and sometimes even to experienced users. Suntar 2.0 may do things at a lower level than Norton or other utilities: e.g. they can show you any sector in a disk partition, but suntar can show you sectors in the partition map, or in a non-Mac partition, or in a disk without a Mac-like partition map.
  4.   Obviously you may follow the method which is typical on the Mac: simply launch the application and experiment. But if you are afraid of doing that, or you have problems, I'll try to explain how the Macintosh handles devices.
  5.   Note that an option ("supported ops" 14) is described in the file about tapes but is meaningful to all people using the  command "Drive list".
  6.  
  7. Devices, drivers and drive numbers
  8.  
  9.   A device, e.g. a hard disk, is not so simple as you may think: at least, there is a number of components and each one changes the rules, that is what must be done to access the device.
  10.   The read/write head on the disk gets and requires analog signals, that is electric signals whose value change with time. The "controller" takes these signals and transforms them into digital signals, i.e. a sequence of binary numbers.
  11.   The controller for the floppy disk is connected directly to the Macintosh, but the applications running on it should never access it direcly, for two reasons: one, Apple may change it in future Macs and you want that your old applications will run on them too; two, chip manufacturers adore making controllers very difficult to use: if they may save a cent in the manufactoring cost but in doing so they make the rules so innatural that a programmer must experiment for a few days before beginning to understand what that chip really does and its manual confusely tried to explain, well, you may bet that's the design which goes into production, and in order to avoid every programmer the burden of handling that chip, Apple has introduced a set of rules to write a "device driver".
  12.   A "device driver" is similar to an application since it runs on your Macintosh, but it's dissimilar from an application since you never see it: only applications see it and they send to it commands like "read the 1000th sector", which the device driver translates into a series of operations on the controller.
  13.   Launch suntar and select the "Drive list" command (in Expert mode): you'll get something like this (obviously without the extra comments):
  14.  
  15. driver nr.  -2 is .Sony  (ROM)                                        don't care, it's duplicated here only for
  16.                                                                                                                                 compatibility with the pre-Mac Plus "HD20"
  17. driver nr.  -4 is .Sound  (ROM)                                    sends sounds to the speaker
  18. driver nr.  -5 is .Sony  (ROM)                                        the floppy disk
  19. driver nr.  -6 is .AIn  (ROM)                                            serial port
  20. driver nr.  -7 is .AOut  (ROM)
  21. driver nr.  -8 is .BIn  (ROM)                                            serial port
  22. driver nr.  -9 is .BOut  (ROM)
  23. driver nr. -33 is .SCSI00  (RAM nonrelocatable)                the internal hard disk
  24. driver nr. -49 is .Display_Video_Apple_V8  (ROM)        even that requires a driver !
  25.  
  26. Some drivers know that the device which is accessed through them may contain a "file system" hence they tell to the System software that a number of "volumes" may be mounted through a "drive number" (don't confuse drives and drivers !): the Drive list command tells also about that (you need not be in Expert mode):
  27.  
  28. drive  1 driver  -5 (.Sony)  Standard floppy disk drive
  29.    SuperDrive (GCR 800k-MFM 720/1440k)  not present
  30. drive  8 driver -33 (.SCSI00) ID=0 fixed disk mounted as "HD40"; blocks=81984
  31.  
  32. Only drives are guaranteed to accept regular read/write commands, hence only device drivers connected to drive numbers may be opened by suntar. Beware: a driver may be connected to many drives and some drivers, just to be sure to have enough drive numbers, create a lot of drives,  that does not hurt the user since before a drive is mounted you don't see it, but that means that you may see drives which don't correspond to any physical device and are marked "not present". 
  33.  
  34.   When you use suntar to open a drive number, suntar talks to the driver which then talks to the hardware: e.g. when you open drive 1 .Sony, suntar will be able to read and write on the internal floppy disk drive.  If you insert a disk when suntar is running but has nothing open it will intercept the event and will check if it's a Macintosh or MS-DOS disk: if it isn't suntar opens the device driver for that drive.
  35.  
  36.  
  37. SCSI hard disks and their drivers
  38.  
  39.   The inclusion of a SCSI port on the Mac Plus introduced a new level of complexity: the SCSI protocol is complex enough to require a small computer which converts the commands specified by the SCSI standard to operations on the controller: that small computer is inside the box containing the disk, and that's why an hard disk for the Mac costs more than a hard disk for a PC clone. The job which usually was performed by the device driver on the Mac is performed by the computer inside the disk box, but a device driver is still needed since the Finder and the applications can speak only the language of the device drivers, not the language of SCSI: such languages are very similar but parameters occupy a different number of bits and are placed in different positions. So, the ".SCSI00" device driver performs the translation for my internal disk "HD40".
  40.    That seems simple, but Apple made things more complex deciding that the device driver for a SCSI device must reside on the disk itself, in a special partition (hard disks are always partitioned, even when you see only one partition). E.g. here is what suntar tells about my hard disk:
  41.  
  42. Partition map test
  43. Disk in Apple format block size=512 number of blocks=82080
  44. partition name="Apple" type="Apple_partition_map" start=1 size=63
  45. partition name="Macintosh" type="Apple_Driver" start=64 size=32  (the device driver)
  46. partition name="MacOS" type="Apple_HFS" start=96 size=81984   (the "HD40" volume)
  47.  
  48.  When the Macintosh boots it performs a few "SCSI READ" commands, if it finds a driver then it loads it, and then the system software does not perform any more any SCSI commands, it only sends driver commands to the driver. Probably Apple was afraid of manufacturers which do not follow the SCSI standard: if the SCSI READ command works, at least for small sector numbers, and the manufacturer provides a formatting utility which writes to the disk a device driver which knows how to do anything else, then that disk may be used on any Mac without having to install any additional software. That's how a driver may compress or encrypt the disk without any incompatibility problem.
  49.   So, a SCSI device may belong to one of these categories:
  50. a) regular disks: the manufacturer may give you some utilities, but if the drive comes formatted for the Mac it may be immediately connected to your Mac and it's mounted on the desktop when you boot
  51. b) non-disks, e.g. printers, scanners, tape units: obviously they'll never be mounted hence the boot procedure will not find a device driver on them. The device is sold with a floppy disk containing some software (maybe a device driver, but often an application) which allows you to use the device: without that software, the device exists only for utilities which talk directly to the SCSI bus, such as SCSIProbe and suntar
  52. c) removable disks: according to Apple rules they should be recognized and mounted only if a disk is present when the Mac boots. That's foolish, and that's why the manufacturer gives you a floppy disk with some software (a device driver !) to be put in the System folder so that the drive list will be correctly updated anyway. However, if the disk is present the device driver in the disk is loaded first, and remains there when you swap disks: a removable disk may happen to be handled by different device drivers according to what you've done with that drive, and that's exactly what Apple wanted to avoid when it decided to put the driver on the disk itself. See the documentation of SCSIProbe for more informations
  53. d) floppy-disk compatibles (e.g. floptical drives, or 1440k drives for Mac Pluses and old SEs): compatibility forbids to put a partition map and a device driver on a standard floppy disk, otherwise it would not be considered a Mac disk when inserted in the internal floppy drive (the .Sony driver does not handle partitions). At least in one case that was solved without requiring software in the system folder, by storing the partition map and the device driver in nonvolatile silicon memory in the SCSI controller and letting it cheat: the SCSI command "READ sector 0" return sector 0 of this fixed partition map telling that there is a device driver partition and a Mac HFS partition: only requesting a sector in the HFS partition one gets data from the real disk.
  54.  
  55.   Suntar may access SCSI devices directly, by sending standard SCSI comands on the SCSI bus, or it may access them through their device driver, if one exists. However, in most cases the two methods are NOT equivalent, since the device driver lets you access a partition, not the entire disk.
  56.   When using suntar to access non-Mac disks in the "normal" cases a) and c), you must open the device as a SCSI ID, since the device driver (if one is loaded) does not see a partition map and issues only error messages or maybe shows a subset of the real disk as the "Mac partition" (some drivers don't read the partition map but use fixed sector numbers as start and end of the Mac partition); in case d) you should use the device driver, since the "Mac partition" is the real disk. For non-disk devices suntar can't open the device driver, if any exists, hence the SCSI ID is the only possible door: obviously printers and scanners don't recognize "read sector" commands: suntar allows you to try, but that's because a rigid refusal would prevent you from using units that do behave like hard disks but do not declare to be hard disks, e.g. Apple's 40 Megabyte tape unit (now out of production and totally obsolete).
  57.   When a device driver or a SCSI device is opened, suntar creates a "Device" menu containing some commands which may be useful: Eject, Mount… there are three different versions of this menu for device drivers, non-tape SCSI devices, tape devices.
  58.   Beware: through the device menu you can directly send some SCSI commands (e.g. stop motor): it's a level of power that I believe no other utility can give you. That's powerful, but it's also dangerous.  Some time ago I stopped the motor of my hard disk, then quitted suntar. Well, the Finder can't restart the motor and suntar was inaccessible on the stopped disk: powering off the Macintosh was the only way to exit from that situation, so now suntar forbids a number of operations on the startup disk, but it may still send very destructive commands: writing to the partition map, for example, and neither Norton nor MacTools can then recover anything on that disk: they talk to the disk through the device driver, which works only when there is a valid partition map. That's why you must pass two levels of alert dialogs (and an "allow write commands" command) before being able to write.
  59.